
<div class="wrap">
            <div class="container">
                <div class="row">
                    <include file="Public/menu" />


<div id="main" class="settings col-md-10 form-horizontal">
    <form id="setting" action="{:U('home/user/passwd')}" method="post">
        <h2 class="h3 mt30 post-title">
            密码修改
        </h2>
        <div class="form-group mt30">
            <label for="oldpassword" class="required control-label col-sm-2">
                当前密码
            </label>
            <div class="col-sm-8">
                <input name="password" placeholder="输入当前密码" name="oldpassword" id="oldpassword" type="password"
                class="form-control" required="">
                <p id="showerror2"></p>
                <p class="help-block mb0">
                    不知道密码？你可以
                    <a href="/user/forgot">
                        重置密码
                    </a>
                </p>
            </div>
        </div>
        <div class="form-group">
            <label for="newpassword" class="required control-label col-sm-2">
                新密码
            </label>
            <div class="col-sm-8">
                <input name="passwordd" placeholder="请输入新密码"  id="newpassword"
                type="password" class="form-control" required="">
                <p id="showerror2"></p>
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="required control-label col-sm-2">
                确认密码
            </label>
            <div class="col-sm-8">
                <input name="passwd" placeholder="确认新密码"  id="password"
                type="password" class="form-control" required="">
                <p id="showerror2"></p>
            </div>
        </div>
        <div class="form-action row">
            <div class="col-sm-10 col-sm-offset-2">
                <button class="btn btn-xl btn-primary password-sub">
                    提交
                </button>
            </div>
        </div>
    </form>
</div>
    <script type="text/javascript">
        $(function() {
            $('#oldpassword').blur(function(event) {
                value = $(this);
                data = $(this).val();
                $.ajax({
                    url: '{:U("home/login/checkpassword")}',
                    type: 'POST',
                    dataType: 'json',
                    data: {password: data},
                })
                .done(function(data) {
                    if (data.error==1) {
                        value.parent().addClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+data.info+'</span>')
                    }else{
                        value.parent().removeClass('has-error');
                        $('#showerror2').html('<span>'+data.info+'</span>')
                    }
                })
            });

            $('#newpassword').blur(function(event) {
                value = $(this);
                data = $(this).val();
                $.ajax({
                    url: '{:U("home/user/checkpassword")}',
                    type: 'POST',
                    dataType: 'json',
                    data: {passwordd: data},
                })
                .done(function(data) {
                    if (data.error==1) {
                        value.parent().addClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+data.info+'</span>')
                    }else{
                        value.parent().removeClass('has-error');
                        value.siblings('#showerror2').html('<span >'+'密码可以用'+'</span>')
                    }
                })
            });

              $('#password').blur(function() {
                value = $(this);
                  passwd = $(this).val();
                  if (!passwd) {
                    value.parent().addClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+'密码不能空'+'</span>')
                  }else if (data===passwd) {
                    value.parent().removeClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+'密码匹配成功'+'</span>')
                  }else{
                    value.parent().addClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+'两次密码不一样'+'</span>')
                  }
                  
                });

                   
        });

    </script>

</div>
</div>
</div>